﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using spk_eAuction.Classes;
namespace spk_eAuction
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            Config.Init(Server.MapPath("~/config/config.xml"));
        }

        protected void Session_Start(object sender, EventArgs e)
        {
            Config.Init(Server.MapPath("~/config/config.xml"));
        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            Config.Init(Server.MapPath("~/config/config.xml"));
        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {
            // Code that runs when an unhandled error occurs
            Exception myEx = Server.GetLastError();
            String RedirectUrlString = "~/Error.aspx?";
            if (myEx.InnerException != null)
            {
                RedirectUrlString += "InnerErr=" + myEx.InnerException.Message.ToString()
                + "&";
            }
            RedirectUrlString += "Err=" + myEx.Message.ToString() + "&";
            if(myEx.TargetSite != null)
                RedirectUrlString += "TargetSite=" + myEx.TargetSite.ToString() + "&";
            RedirectUrlString += "StackTrace=" + myEx.StackTrace.ToString();

            Response.Redirect(RedirectUrlString);
        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}